"""
File: home_page.py
Author: ershixiong
Date: 2023/11/23
describe:

"""
from time import sleep

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from project202311_wework.wework.wework_po.page_object.base_page import BasePage
from project202311_wework.wework.wework_po.utiles.log_utils import logger


class HomePage(BasePage):
    BASE_URL = 'https://work.weixin.qq.com/wework_admin/frame#index'
    __ELE_MENU_CONTACTS = (By.XPATH, '//*[text()="通讯录"]')
    __BTN_GO_ADD_MEMBER = (By.XPATH, '//*[text()="添加成员"]')

    def goto_contract_page(self):
        logger.info('首页，点击通讯录菜单')
        self.do_click(*self.__ELE_MENU_CONTACTS)

        from project202311_wework.wework.wework_po.page_object.contacts_page import ContractsPage
        return ContractsPage(self.driver)

    def goto_member_add_page(self):
        logger.info('首页，点击添加成员按钮')
        sleep(1)
        self.do_click(self.__BTN_GO_ADD_MEMBER)

        from project202311_wework.wework.wework_po.page_object.member_add_page import MemberAddPage
        return MemberAddPage(self.driver)
